package com.jn.musicdemo2.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.jn.musicdemo2.service.MusicService;

// 接收通知按钮点击事件的广播接收器
public class NotificationReceiver extends BroadcastReceiver {
    // 定义动作常量
    public static final String ACTION_PREV = "com.jn.customnotification.ACTION_PREV";
    public static final String ACTION_PLAY_PAUSE = "com.jn.customnotification.ACTION_PLAY_PAUSE";
    public static final String ACTION_NEXT = "com.jn.customnotification.ACTION_NEXT";

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent == null || intent.getAction() == null) {
            return;
        }

        // 将收到的广播转发给服务处理
        Intent serviceIntent = new Intent(context, MusicService.class);
        serviceIntent.setAction(intent.getAction());
        context.startService(serviceIntent);
    }
}
    